/**
 * 北京钉图互动科技 all right reserver
 */
package com.impress.commons.msgpack;

import org.msgpack.jackson.dataformat.MessagePackFactory;

import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * @author Wangyi
 * @since 2016年6月20日
 */
public class MsgPackSerializerHelper {

	private MsgPackSerializerHelper() {
	}

	public static final byte[] EMPTY_ARRAY = new byte[0];
	public static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(new MessagePackFactory());

	static {
		// 设置输入时忽略在JSON字符串中存在但Java对象实际没有的属性
		OBJECT_MAPPER.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
		// 只输出初始值被改变的属性到Json字符串的Mapper, 最节约的存储方式
		OBJECT_MAPPER.setSerializationInclusion(Include.NON_DEFAULT);
	}
}
